Upgrade to Zustand 5.x#1405
Open
IDisposable wants to merge 2 commits into
Open
Conversation
6ef30ce to
30bcb22
Compare
30bcb22 to
20318a6
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Upgrades the UI state-management layer to Zustand 5.x and adapts store typing/selector usage in device settings routes to reduce unnecessary re-renders and prevent leaks, plus a small container build script adjustment.
Changes:
- Bump
zustandfrom^4.5.2to^5.0.12(and update lockfile). - Refactor
NetworkStatestore typing and update network/general settings pages to useuseShallowselectors and fix asetIntervalleak pattern. - Add a Git
safe.directoryconfiguration in the CGO native build script for container builds.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/src/routes/devices.$id.settings.network.tsx | Switch to useShallow selector for network state fields; remove RTC-ready helper; adjust LifeTimeLabel effect. |
| ui/src/routes/devices.$id.settings.general._index.tsx | Use useShallow selector for version fields from the device store. |
| ui/src/hooks/stores.ts | Split NetworkState data from store actions via NetworkStateStore; update DHCP lease expiry immutably. |
| ui/package.json | Upgrade Zustand dependency to ^5.0.12. |
| ui/package-lock.json | Lockfile updates for Zustand 5.x and its peer dependency metadata. |
| scripts/build_cgo.sh | Add git config --global --add safe.directory ... before native build. |
Files not reviewed (1)
- ui/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
terryrankine
added a commit
to terryrankine/kvm
that referenced
this pull request
May 7, 2026
- Bump zustand to ^5.0.12 in package.json and update lockfile - Split NetworkState into pure data interface and NetworkStateStore (store interface extending it with action methods) — fixes type leakage of store actions into data-only consumers - Replace mutable DHCP lease update with immutable spread to prevent stale-reference bugs in Zustand 5 - Add useShallow selectors to useNetworkStateStore and useDeviceStore callers that returned plain objects, preventing spurious re-renders in Zustand 5 where object identity is always checked Fork-specific: VPN, audio, and IO stores are not in upstream and were not touched. Only NetworkStateStore and DeviceStore call sites in VersionContent and NetworkContent were updated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrade to current version of Zustand.
NetworkStatestore instores.tsto be passing around the data, not the data+mutators.devices.$id.settings.network.tsxto useuseShallowon each of the individual properties of theNetworkStateinstead of the entire block of state so we don't re-render on any change.useShallowfor version information indevices.$id.settings.general._index.tsxdevices.$id.settings.network.tsxinLifeTimeLabelmount'suseEffectresolveOnRtcReadyindevices.$id.settings.network.tsxas it leaks a subscription when things were not ready. The code injsonrpc.tswaitForRtcReadyhandles this much more robustly.devices.$id.settings.network.tsxgit config --global --add safe.directoryin thebuild_cgo.shfor Docker native library buildsChecklist
make test_e2elocally and passedNote
Medium Risk
State management was upgraded and several components changed their store selectors/mutators, which can subtly affect re-render behavior and network settings UI state updates. Also adjusts Docker/native build scripting, which could impact CI/build environments.
Overview
Upgrades UI state management to
zustand@5(updatespackage.json/lockfile) and adjusts call sites to use the newzustand/shallowhelper for stable, minimal subscriptions.Refactors
useNetworkStateStoretyping and updates DHCP lease mutation to be immutable, and updates the network/general settings routes to select only needed store fields (reducing re-renders). Also fixes aLifeTimeLabelinterval bug (no leaked interval / proper immediate update), removes a leaky RTC readiness helper in favor of the existing JSON-RPC readiness logic, and drops a redundant DHCP success toast.Adds a
git config --global --add safe.directorystep inscripts/build_cgo.shto avoid safe-directory errors when building the native library in Docker.Reviewed by Cursor Bugbot for commit 2381c2c. Bugbot is set up for automated code reviews on this repo. Configure here.